package com.github.jspxnet.worktask.table;

import com.github.jspxnet.boot.environment.Environment;
import com.github.jspxnet.enums.BoolEnumType;
import com.github.jspxnet.enums.CongealEnumType;
import com.github.jspxnet.enums.RecycleEnumType;
import com.github.jspxnet.enums.YesNoEnumType;
import com.github.jspxnet.json.JsonIgnore;
import com.github.jspxnet.sober.annotation.Column;
import com.github.jspxnet.sober.annotation.Id;
import com.github.jspxnet.sober.annotation.Nexus;
import com.github.jspxnet.sober.annotation.Table;
import com.github.jspxnet.sober.enums.MappingType;
import com.github.jspxnet.sober.table.OperateTable;
import com.github.jspxnet.utils.StringUtil;
import com.github.jspxnet.worktask.model.enums.SupervisePowerEnumType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by jspx.net
 *
 * author: chenYuan
 * date: 2020/9/8 21:59
 * description:  配置的工作流任务 索引表
 *
 * 流程配置,节点都在 nodeList
 * 流程配置表 这里是流程的总表,和通用配置
 * */
@EqualsAndHashCode(callSuper = true)
@Table(name = "jwf_work_flow", caption = "流程配置表",cache = false)
@Data
public class ConfWorkFlow extends OperateTable  {
    @Id
    @Column(caption = "ID", notNull = true)
    private long id = 0;

    @Column(caption = "流程编号", length = 32, notNull = true)
    private String flowNo = StringUtil.empty;

    @Column(caption = "命名空间", length = 50, dataType = "isLengthBetween(1,50)")
    private String namespace = StringUtil.empty;

    @Nexus(mapping = MappingType.OneToMany, field = "flowNo", targetField = "flowNo",term = "namespace:eq[${namespace}]",targetEntity = ConfFlowNode.class,save = true,update = true,chain = true)
    private List<ConfFlowNode> nodeList = new ArrayList<>();

    @Column(caption = "标题", length = 50, notNull = true)
    private String title = StringUtil.empty;

    @Column(caption = "备注", length = 250)
    private String note = StringUtil.empty;

    //关联字典表
    @Column(caption = "分类",length = 50)
    private String flowGroup = Environment.defaultValue;

    @Column(caption = "收文是否提醒",option = "0:不提醒",enumType = BoolEnumType.class,input="radio")
    private int receivingTip = YesNoEnumType.YES.getValue();

    //默认配置-----------begin
    @Column(caption = "归档",length = 2,enumType = BoolEnumType.class,input="radio")
    private int canArchive = BoolEnumType.YES.getValue();

    @Column(caption = "允许修改附件",length = 2,enumType = BoolEnumType.class,input="radio")
    private int canEditAttachment = BoolEnumType.YES.getValue();

    @Column(caption = "允许修改流程",length = 2,enumType = BoolEnumType.class,input="radio")
    private int canModifyFlow = BoolEnumType.YES.getValue();

    @Column(caption = "允许空意见",length = 2,enumType = BoolEnumType.class,input="radio")
    private int canEmptyOpinion  = BoolEnumType.YES.getValue();

    @Column(caption = "提醒方式",option = "0:不提醒",enumType = BoolEnumType.class,input="radio")
    private int taskTipType = BoolEnumType.NO.getValue();

    @Column(caption = "收到文件后几分钟提醒一次",option = "0:不提醒")
    private int tipMinute = 48;

    @Column(caption = "提醒触发",length = 5000)
    private String tipScript = StringUtil.empty;

    //流程期限
    @Column(caption = "默认多少天超期")
    private int limitDate = 30;

    //option = "0:一直等待",
    @Column(caption = "到期限后是否终结",enumType = BoolEnumType.class,input = "radio")
    private int limitDateEnd = BoolEnumType.NO.getValue();

    @Column(caption = "督办人员", length = 4000)
    private String superviseUsers = StringUtil.empty;

    @Column(caption = "督办权限",enumType = SupervisePowerEnumType.class,input = "select")
    private int supervisePower = SupervisePowerEnumType.NONE.getValue();

    //默认配置-----------end
    @Column(caption = "冻结",length = 2, enumType = CongealEnumType.class , notNull = true,input = "select")
    private int congealType = CongealEnumType.NO_CONGEAL.getValue();

    @JsonIgnore
    @Column(caption = "是否在回收站", length = 2, enumType = RecycleEnumType.class, notNull = true,input = "select")
    private int recycleType = RecycleEnumType.NO_RECYCLE.getValue();

    @JsonIgnore
    @Column(caption = "回收时间")
    private Date recycleDate = new Date();

    @Column(caption = "排序", option = "0:默认;2:固顶;4:置顶;8:结对置顶;-1:下沉", notNull = true,input = "select")
    private int sortType = 0;

    @JsonIgnore
    @Column(caption = "排序时间", notNull = true)
    private Date sortDate = new Date();


}
